#include <iostream>
#include "manager.h"
#include "tools.h"
#include "managerservice_impl.h"
#include <vector>

using namespace std;

bool ManagerServicelmpl::addManager(Manager manager)
{
	  
	vec.push_back(manager);
	cout<<"success"<<endl;
	dao->save(vec);
	return true;	
}

bool ManagerServicelmpl::deleteManager(int id)
{
	vector<Manager>::iterator temp;
	for(temp = vec.begin();temp != vec.end();temp++)
	{
		if(temp->get_manager_id() == id)
		{
			vec.erase(temp);
			cout << "delete success"<<endl;
			dao->save(vec);
			return true;
		}	
	}
	cout << "delete false"<<endl;
	return false;
}

vector<Manager> ManagerServicelmpl::listManager()
{	
	for(unsigned int i=0; i<vec.size(); i++)
	{
		cout << vec[i].get_manager_id() << " " << vec[i].get_manager_name() << endl;
	}
	return vec;
}
